package org.webby.mappers;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA.
 * User: samp
 * Date: Apr 17, 2007
 * Time: 4:20:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class PatternMap {
  private List<Pattern> patterns = new ArrayList<Pattern>();
  private List<Attribute> attributes = new ArrayList<Attribute>();

  public PatternMap(String pattern) {
    addPattern(pattern);
  }

  public PatternMap(String pattern, String name, String value) {
    this(pattern);
    addAttribute(new Attribute(name, value));
  }

  public PatternMap(String pattern, String name, int group) {
    this(pattern);
    addAttribute(new Attribute(name, group));
  }

  public void addPattern(String pattern) {
    patterns.add(Pattern.compile(pattern));
  }

  public List<Pattern> getPatterns() {
    return patterns;
  }

  public List<Attribute> getAttributes() {
    return attributes;
  }

  public void addAttribute(Attribute attribute) {
    attributes.add(attribute);
  }

}
